package itheima04;

import java.io.*;

/*
    我给你FileInputStream和FileOutputStream两个流,
    转换成BufferedReader缓冲字符输入流和BufferedWriter缓冲字符输出流
    按行复制文本文件
 */
public class Demo04ConvertStream {
    public static void main(String[] args) throws IOException {
        //字节输入流
        InputStream is  = new FileInputStream("day14\\from\\f1.txt");
        OutputStream os = new FileOutputStream("day14\\upload\\f1.txt");

        //InputStream ---> InputStreamReader (Reader的子类)
        Reader r = new InputStreamReader(is);

        //InputStreamReader (Reader的子类) --> BufferedReader
        BufferedReader br = new BufferedReader(r);

        //OutputStream ---> OutputStreamWriter(Writer的子类)
        Writer w = new OutputStreamWriter(os);

        //OutputStreamWriter(Writer的子类)--> BufferedWriter
        BufferedWriter bw = new BufferedWriter(w);

        //按行循环读写
        String line = null;
        while((line = br.readLine())!=null) {
            bw.write(line);
            bw.newLine();
        }

        br.close();
        bw.close();
    }
}
